package com.jwell.panprovider.model

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.panprovider.application.App
import com.jwell.panprovider.contract.PreRegisterContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by 76577 on 2018/4/9.
 * 预登记
 */
class PreRegisterModel : PreRegisterContract.Model, BaseModel() {
    override fun createWaybill(data: RequestData, baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("预登记" + data.toString())
        getApiStore().createFroExportWaybill(data)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    //  measurementType (integer, optional): 计量类型 1、外购-辅料 2、外购-其它 3、外购-大宗原燃料 4、外销 5、厂际 6、其它 = ['1', '2', '3', '4', '5', '6'],
    //    measurementMethod (integer, optional): 计量方式 1、先重后空 2、先空后重 3、标证出皮 4、只称重车 5、只称空车 = ['1', '2', '3', '4', '5'],
//    materialName (string, optional): 物质名称 ,
//    receivingUnit (string, optional): 收货单位 ,
//    forwardingUnit (string, optional): 发货单位 ,
//    waybill (Array[Logistics.Application.QueuingSystems.Dto.ForExportWaybills.CreateForExportWaybillDto], optional): 调度信息
    data class RequestData(var measurementType: Int? = null, var measurementMethod: Int? = null,
                           var materialName: String? = null, var receivingUnit: String? = null,
                           var forwardingUnit: String? = null,
                           var waybill: List<DriverInfo>? = null
    )

    //    driverName (string, optional): 司机名称 ,
//    carNum (string, optional): 车牌号 ,
//    driverPhone (string, optional): 司机电话 ,
//    id (integer, optional)
    data class DriverInfo(var driverName: String? = null,
                          var carNum: String? = null,
                          var driverPhone: String? = null,
                          var id: Int? = null)
}